package com.dev.base.expand.mvp;

import com.dev.base.able.IBaseView;
import com.dev.base.utils.AbilityUtils;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.ability.Lifecycle;
import ohos.aafwk.content.Intent;
import ohos.agp.components.ComponentContainer;

/**
 * MVP View层基类
 * @param <VM>
 */
public abstract class BaseMVPSlice<VM extends BasePresenter> extends AbilitySlice {
    private ComponentContainer contentContainer;
    private Lifecycle lifecycle;
    private int layout = 0;
    private IBaseView iBaseView;
    protected VM viewModel;
    protected boolean ifIsThisSlice;
    public void setiBaseView(IBaseView iBaseView) {
        this.iBaseView = iBaseView;
    }

    @Override
    protected void onStart(Intent intent) {
        super.onStart(intent);
        contentContainer = AbilityUtils.getContentContainer(iBaseView.getAbilitySliceContext(), iBaseView.getLayout());
        setUIContent(contentContainer);
        ifIsThisSlice=true;

    }
    @Override
    public void onActive() {
        super.onActive();
        ifIsThisSlice=true;
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
        ifIsThisSlice=false;
    }

    @Override
    protected void onInactive() {
        super.onInactive();
    }


}
